<script type="text/javascript" language="javascript" charset="utf-8">
$(".menu-wrap li").removeClass("active-link");
$(".menu-wrap #potential_student").addClass("active-link");
</script>
<div class="mask">
</div>
<div class="common-tit">
  <h2>意向学员列表</h2>
  <span>招生管理 > 意向学员列表</span>
  <a class="add-staff" href="/admin/potential_students/new">添加意向学员</a>
</div>
<div class="cur-list">
  <div class="cur-listbox clearfix">
    <div class="cur-ll clearfix">
      <div class="list-box">
        <div class="downbtn">
          <span data_id="all">请选择性别</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">请选择性别</li>
          <% Company::GENDER.each do |key,value| %>
            <li data_id="<%= key %>"><%= value %></li>
          <%end%>
        </ul>
      </div>
      <div class="list-box">
        <div class="downbtn">
          <span data_id="all">请选择年龄分组</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">请选择年龄分组</li>
          <% Company::AGE_GROUP.each do |key, value| %>
            <li data_id="<%= key %>"><%= value %></li>
          <%end%>
        </ul>
      </div> <div class="list-box">
        <div class="downbtn">
          <span data_id="all">请选择状态</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">请选择状态</li>
          <li data_id="未转化">未转化</li>
          <li data_id="已转化">已转化</li>
        </ul>
      </div>
      <div class="i-search">
        <!-- <em></em> -->
        <input id="searchStu" type="text" placeholder="请输入要搜索学员的手机或名字">
      </div>
    </div>
  </div>
  <div class="curlist-con">
    <div class="scrollbox">
      <table>
        <thead>
          <tr>
            <th class="inten-name">姓名</th>
            <th class="inten-sex">性别</th>
            <th class="inten-tel">电话</th>
            <th class="inten-g">分组</th>
            <th class="inten-age">年龄阶段</th>
            <th class="inten-s">状态</th>
            <th class="curl-operation">操作</th>
          </tr>
        </thead>
        <tbody>
          <% @potential_students.each do |potential_student| %>
          <tr>
            <td><%= potential_student.name %></td>
            <td><%= potential_student.sex %></td>
            <td><%= potential_student.mobile %></td>
            <td><%= potential_student.student_group_configuration.group_name if potential_student.student_group%></td>
            <td><%= potential_student.student_age_group %></td>
            <td><%= potential_student.status %></td>
            <td class="curl-operation">
              <span>[</span>
              <em><%= link_to "查看详情", admin_potential_student_path(potential_student) %></em>
              <span>]</span>
              <span>[</span>
              <em ><%= link_to "添加回访", new_remark_admin_potential_students_path(potential_student_id: potential_student.id), remote: true %></em>
              <span>]</span>	
            </td>
          </tr>
          <% end %>
        </tbody>
      </table>
      <div class="apple_pagination">
        <%= paginate @potential_students, :container => false %>
      </div>
    </div>
  </div>
</div>
<script src="/assets/js/common.js"></script>
<script>
// 弹窗
  $(".cur-ll .list-box li").on("click", function() {
    $(this).parent().parent().find("span").attr("data_id", $(this).attr("data_id"));
    transData();
  });
  $("#searchStu").change(function() {
    if ($(this).val() != "") {
      transData();
    }
  });
 function transData() {
  var transD = "";
  for (var i = 0; i < $(".cur-ll .list-box").length; i++) {
    switch(true) {
      case i == 0: transD += "sex" + "=" + $($(".cur-ll .list-box")[i]).find("span").attr("data_id") + "&";break;
      case i == 1: transD += "age_group" + "=" + $($(".cur-ll .list-box")[i]).find("span").attr("data_id") + "&";break;
      case i == 2: transD += "status" + "=" + $($(".cur-ll .list-box")[i]).find("span").attr("data_id");break;
    };
  };
  if ($("#searchStu").val() != "") {
    transD += "&" + "search_student" + "=" + $("#searchStu").val();
  };
  $.ajax({
    type:'get', url:"/admin/potential_students/get_student_list?"+ transD,
    success: function(data) {
      if (data.error) {
        // console.log("wrong");
      } 
    }
  });
}
</script>
